package com.zheng.study.company.entity;

import javax.persistence.*;
import java.util.Set;

/**
 * 职权
 * ============================================================================
 * author : dzw
 * createDate:  2018/8/24 。
 * ============================================================================
 */
//@Entity
//@Table(name = "sys_power")
public class Power extends CompanyEntity {
	private static final long serialVersionUID = 4649580042443873192L;

	/**
	 * 部门
	 */
	private Department department;
	/**
	 * 岗位
	 */
	private Post post;
	/**
	 * 描述
	 */
	private String description;
	/**
	 * 父节点
	 */
	private Power parent;
	/**
	 * 子节点
	 */
	private Set<Power> powerSet;
	/**
	 * 自定义序号排序
	 */
	private Integer sortNo;

	@ManyToOne(fetch = FetchType.LAZY)
	public Department getDepartment() {
		return department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	public Post getPost() {
		return post;
	}

	public void setPost(Post post) {
		this.post = post;
	}

	@Column(length = 4000)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	public Power getParent() {
		return parent;
	}

	public void setParent(Power parent) {
		this.parent = parent;
	}

	@OneToMany(mappedBy = "parent", fetch = FetchType.LAZY)
	@OrderBy("name asc")
	public Set<Power> getPowerSet() {
		return powerSet;
	}

	public void setPowerSet(Set<Power> powerSet) {
		this.powerSet = powerSet;
	}

	public Integer getSortNo() {
		return sortNo;
	}

	public void setSortNo(Integer sortNo) {
		this.sortNo = sortNo;
	}
}
